package cn.dai.pojo;

import lombok.Data;


@Data
public class ResultData<T> {
    private String status;
    private String message;
    private T data;
    private long timestamp;


    public ResultData() {
        this.timestamp = System.currentTimeMillis();
    }

    public static <T> ResultData<T> success(T data) {
        ResultData<T> resultData = new ResultData<>();
        resultData.setStatus(ReturnCode.SUCCESS.getStatus());
        resultData.setMessage(ReturnCode.SUCCESS.getMessage());
        resultData.setData(data);
        return resultData;
    }

    public static <T> ResultData<T> fail(String status, String message) {
        ResultData<T> resultData = new ResultData<>();
        resultData.setStatus(status);
        resultData.setMessage(message);
        return resultData;
    }

}
